package com.cruel_wandering.wifi_geo_predictor;

import java.util.HashMap;
import java.util.Map;

import android.os.Bundle;
import android.preference.PreferenceActivity;

@SuppressWarnings("serial")
public class Preferences extends PreferenceActivity
{
	static public final String MAY_USE_GPS = "use_GPS";
	static public final String MAY_USE_CELLID = "use_CellID";
	static public final String MIN_POLLING_INTERVAL = "min_interval";
	static public final String MAX_POLLING_INTERVAL = "max_interval";
    static public final String DEBUG_MODE = "debug_mode";
    static public final String WIFI_SIMULATOR = "wifi_sim";

  static private final Map<String, String> key2fieldName = new HashMap<String, String>(){{
		put(DEBUG_MODE, "Debug mode");
		put(MAY_USE_CELLID, "May use CellId");
		put(MAY_USE_GPS, "May use GPS");
		put(MIN_POLLING_INTERVAL, "Min polling interval");
		put(MAX_POLLING_INTERVAL, "Max polling interval");
		put(WIFI_SIMULATOR, "Use Wifi Simulator");
	}};

  static private final Map<String, Integer> key2id = new HashMap<String, Integer>(){{
		put(DEBUG_MODE, R.id.debug_mode);
		put(MAY_USE_CELLID, R.id.pref_use_CellID);
		put(MAY_USE_GPS, R.id.pref_use_GPS);
		put(MIN_POLLING_INTERVAL, R.id.max_interval);
		put(MAX_POLLING_INTERVAL, R.id.max_interval);
		put(WIFI_SIMULATOR, R.id.wifi_sim);
	}};

  @Override
  protected void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.preferences);
  }

  public static String getFieldName(String key)
  {
  	String res = key2fieldName.get(key);

  	return res == null ? "" : res;
  }

  public static int getId(String key)
  {
  	Integer res = key2id.get(key);

  	return res == null ? -1 : res;
  }
}
